package com.ftg.learn.mapper;

import com.ftg.learn.pojo.Xinwen;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface XinwenMapper {
    //查找
    @Select("select * from xinwen limit #{arg0},#{arg1}")
    public List<Xinwen> showall(int begin, int end);
    //查一
    @Select("select * from xinwen where xinwen_id = ifnull(concat(#{xinwen_id},%),xinwen_id) or xinwen_bt like ifnull(concat(#{xinwen_bt},%),xinwen_bt)")
    public List<Xinwen> findone(String xinwen_id, String xinwen_bt);
    //总共多少条
    @Select("select count(*) from xinwen")
    int getcount();
    //添加
    @Insert("insert into xinwen(xinwen_id,xinwen_bt,xinwen_nr,xinwen_img)values(#{xinwen_id},#{xinwen_bt},#{xinwen_nr},#{xinwen_img})")
    public int add(Xinwen xinwen);
    //删除
    @Delete("delete from xinwen where xinwen_id = #{xinwen_id}")
    public int delete(String xinwen_id);
    //修改
    @Update("update xinwen set xinwen_id = #{xinwen_id},xinwen_bt = #{xinwen_bt},xinwen_nr = #{xinwen_nr},xinwen_img = #{xinwen_img} where xinwen_id=#{xinwen_id}")
    public int update(Xinwen xinwen);
}
